package com.qingke.besuper.command.impl;

import java.util.List;

import com.qingke.besuper.command.UserCommand;
import com.qingke.besuper.pojo.Answer;
import com.qingke.besuper.pojo.Question;
import com.qingke.besuper.pojo.User;
import com.qingke.besuper.util.BeSuperConsole;

public class ScoreCommand extends UserCommand{

	public ScoreCommand(User user) {
		super(user);
	}

	@Override
	public void execute() {
		
		List<Question> arrQ=dao.getMineQuestions(user.getId());
		BeSuperConsole.println("your questions:"+arrQ.size());

		
		List<Answer> arrA=dao.getAnswersByUserId(user.getId());
		BeSuperConsole.println("your answers:"+arrA.size());

		List<Question> arrAllQ=dao.getAllQuestions();
		int getPoint=0;
		for(Question q:arrAllQ){
			for(Answer a:arrA){
				if(q.getBestAnswerId()==a.getId())
					getPoint+=q.getCredit();
			}
		}
		BeSuperConsole.println("the credit you get:"+getPoint);
		
		int setPoint=0;
		for(Question q:arrQ){
			setPoint+=q.getCredit();
		}
		BeSuperConsole.println("the credit you set:"+setPoint);
		
		BeSuperConsole.println("your score:"+user.getScore());
		
		
	}

}
